<template>
 <div>
   <div style="margin-bottom: 20px;">
      <el-space wrap>
    <!-- 搜索 -->
      <el-input
        class="logInput"
        placeholder="请输入用户ID"
        v-model="text"
      />
      <el-button
        type="primary"
        @click="onSearch"
      ><span class="iconfont icon-sousuo"></span>查找</el-button>
  </el-space>
   </div>
    <!-- //表格 -->
    <div class="tableBox">
      <el-table
        :data="tableData"
        border
      >
        <el-table-column
          prop="id"
          label="地址ID"
        />
        <el-table-column
          prop="userId"
          label="用户ID"
        />
        <el-table-column
          prop="consignee"
          label="签收人"
        />
        <el-table-column
          prop="phone"
          label="手机号"
        />
        <el-table-column
          prop="province"
          label="省份"
        />
        <el-table-column
          prop="city"
          label="城市"
        />
        <el-table-column
          prop="county"
          label="区/县"
        />
        <el-table-column
          prop="address"
          label="详细地址"
        />
      </el-table>
      <!-- //分页 -->
    <daily-demo
      v-bind="demo"
      @pages="pages"
      @limits="limits"
    ></daily-demo>
    </div>
 </div>
</template>
<script>
import http from "@/util/http";
import DailyDemo from "@/components/DailyOperation/Demo.vue";
export default {
  components:{
    DailyDemo
  },
  data() {
    return {
      text: "", //查找
      // 用户列表信息
      tableData: [],
      demo: {
        page: 1,
        limit: 10,
        total: 10, //分页--总条数
      },
    };
  },
  created() {
    // 地址列表请求
    this.addressMange();
  },
  methods: {
    onSearch() {
        this.addressMange()
    },
    // 地址列表请求
    addressMange() {
      let userData = {
        _gp: "admin.address",
        _mt: "list",
        page: this.demo.page,
        limit: this.demo.limit,
        userId: this.text,
      };
      http.post(userData).then((res) => {
        console.log(res, "用户列表请求成功");
        this.tableData = res.data.data.items
        this.demo.total = res.data.data.total
      });
    },
    //分页---当前页数
    pages(e) {
      console.log(e,456);
      this.demo.page = e;
      this.addressMange();
    },
    // 分页---每页显示条目个数
    limits(e) {
      this.demo.limit = e;
      this.addressMange();
    }
  },
};
</script>
